home *** CD-ROM | disk | FTP | other *** search
- (*$V-,R-,B-*)
- Program PctQmd;
-
- (* --------------------------------------------------------------------- *)
- (* *)
- (* Program: PctQmd *)
- (* *)
- (* Purpose: Converts PC-Talk phone directory to QMODEM phone *)
- (* directory. *)
- (* *)
- (* *)
- (* Usage: Execute 'PCTQMD.COM'. *)
- (* *)
- (* The PC-Talk phone directory file PC-TALK.DIR must be *)
- (* in the current DOS directory when this program is run. *)
- (* *)
- (* The existence of the file PC-TALK.DIR is verified. If *)
- (* it cannot be opened the program aborts. Likewise, the *)
- (* program aborts if the file QMODEM.FON cannot be opened *)
- (* for output. *)
- (* *)
- (* After verifying that the two directory files can be *)
- (* opened, prompts are issued for the default baud rate, *)
- (* parity, character size, and stop bits. These data are *)
- (* used to construct a default QMODEM directory record to *)
- (* pad out any remaining unfilled records in the QMODEM *)
- (* directory. *)
- (* *)
- (* I/O errors when reading or writing result in a program *)
- (* abort, and the QMODEM directory file is erased. *)
- (* *)
- (* PC-Talk allows for Odd parity, but QMODEM currently *)
- (* does not. Hence, all PC-Talk entries for Odd parity *)
- (* are changed to No parity. *)
- (* *)
- (* Remarks: As an alternative to prompting for the default Qmodem *)
- (* parameters, those previously set for PC-Talk could be *)
- (* used. Also, the dialing prefixes from some versions of *)
- (* PC-Talk could be mapped to the corresponding QMODEM *)
- (* prefix numbers. *)
- (* *)
- (* Author: Philip R. Burns *)
- (* December 15, 1984 *)
- (* *)
- (* Note: Comments and suggestions for changes are welcome. *)
- (* Leave a message on Gene Plantz's BBS at (312) 882 4145 *)
- (* or Ron Fox's BBS at (312) 940 6494. *)
- (* *)
- (* --------------------------------------------------------------------- *)
-
- Const
- (* QMODEM phone directory size *)
- Size_Of_Qmodem_File = 200;
- (* Initial records to ignore in *)
- (* PC-TALK.DIR *)
- PcTalk_Ignore = 4;
-
- Type
- (* To match any size string parameter *)
- AnyStr = String[255];
- (* Parity type in Qmodem *)
- Check_Bit = ( None, Even );
-
- (* QMODEM phone directory file format *)
- Qmodem_Record = Record
- Name: String[25];
- Number: String[14];
- Speed: Integer;
- Dbits: Integer;
- Sbits: Integer;
- Parity: Check_Bit;
- End;
- (* PC-Talk phone directory file format *)
-
- PcTalk_Record = Record
- Name: Array[ 1 .. 24 ] Of Char;
- Filler1: Array[ 1 .. 22 ] Of Char;
- Number: Array[ 1 .. 14 ] Of Char;
- Filler2: Array[ 1 .. 2 ] Of Char;
- Speed: Array[ 1 .. 4 ] Of Char;
- Parity: Char;
- Dbits: Char;
- Sbits: Char;
- Filler3: Array[ 1 .. 59 ] Of Char;
- End;
-
- Var
- (* QMODEM phone directory file *)
- QmodemF : File of Qmodem_Record;
-
- (* PC-Talk phone directory file *)
- PcTalkF : File of PcTalk_Record;
-
- (* Entry for QMODEM directory file *)
- Qmodem_Entry : Qmodem_Record;
- (* Default entry for QMODEM file *)
- Default_Qmodem_Entry: Qmodem_Record;
- (* Entry for PC-Talk directory file *)
- PcTalk_Entry: PcTalk_Record;
- (* Number of PC-Talk entries *)
- PcTalk_Count: Integer;
-
- (* --------------------------------------------------------------------- *)
- (* TRIM --- Remove leading and trailing blanks from string *)
- (* --------------------------------------------------------------------- *)
-
- Function Trim( S: AnyStr ) : AnyStr;
-
- (* --------------------------------------------------------------------- *)
- (* *)
- (* Function: Trim *)
- (* *)
- (* Purpose: Removes leading and trailing blanks from a string. *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Trimmed_String := TRIM( S : Anystr ) : Anystr; *)
- (* *)
- (* S --- String to be trimmed *)
- (* Trimmed_String --- String after trimming *)
- (* *)
- (* Calls: Copy, Length *)
- (* *)
- (* Called By: Transfer_Entries *)
- (* *)
- (* --------------------------------------------------------------------- *)
-
- Var
- I : Integer;
- J : Integer;
- L : Integer;
-
- Begin (* Trim *)
-
- L := LENGTH( S );
- J := L;
-
- While ( J > 1 ) AND ( S[J] = ' ' ) Do
- J := J - 1;
-
- I := 1;
-
- While ( I <= L ) AND ( S[I] = ' ' ) Do
- I := I + 1;
-
-
- Trim := Copy( S, I, J - I + 1 );
-
- End (* Trim *);
-
- (* --------------------------------------------------------------------- *)
- (* IO_Check --- Check for and Abort if IO error found *)
- (* --------------------------------------------------------------------- *)
-
- Procedure IO_Check( Message : AnyStr; Record_Number : Integer );
-
- (* --------------------------------------------------------------------- *)
- (* *)
- (* Procedure: IO_Check *)
- (* *)
- (* Purpose: Checks for and aborts in case of IO error *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* IO_Check( Message : AnyStr; Record_Number : Integer ); *)
- (* *)
- (* Message --- Message text to abort with if IO error found *)
- (* Record_Number --- Record in which IO error occurs *)
- (* *)
- (* Calls: IOResult, Halt *)
- (* *)
- (* Called By: PctQmd *)
- (* *)
- (* --------------------------------------------------------------------- *)
-
- Begin (* IO_Check *);
-
- If IOResult <> 0 Then
- Begin
- Writeln( Message, ', record = ', Record_Number );
- Erase( QmodemF );
- Close( QmodemF );
- Close( PcTalkF );
- Halt;
- End;
-
- End (* IO_Check *);
-
- (* --------------------------------------------------------------------- *)
- (* Open_Files --- Open PC-Talk and QMODEM directory files *)
- (* --------------------------------------------------------------------- *)
-
- Procedure Open_Files;
-
- (* --------------------------------------------------------------------- *)
- (* *)
- (* Procedure: Open_Files *)
- (* *)
- (* Purpose: Opens the PC-Talk and QMODEM directory files *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Open_Files; *)
- (* *)
- (* Calls: Assign, Reset, Rewrite, IOResult, Halt *)
- (* *)
- (* Called By: PctQmd *)
- (* *)
- (* --------------------------------------------------------------------- *)
-
- Var
- YesNo : Char;
-
- Begin (* Open_Files *)
- (* Verify that PC-TALK.DIR exists. *)
- (* Abort if not found. *)
- Assign( PcTalkF , 'PC-TALK.DIR' );
- (*$I-*)
- Reset( PcTalkF );
- (*$I+*)
-
- If IOResult <> 0 Then
- Begin
- Writeln(' Can''t open the PC-TALK.DIR file for input.');
- Halt;
- End;
- (* Check if a QMODEM.FON file *)
- (* already exists. If so, ask *)
- (* if it should be trashed. *)
- Assign( QmodemF , 'QMODEM.FON' );
- (*$I-*)
- Reset( QmodemF );
- (*$I+*)
-
- If IOResult = 0 Then
- Begin
-
- Writeln('QMODEM dialing directory file QMODEM.FON already exists.');
- Writeln('Continuing to run this program will overwrite it. ');
-
- Repeat
- Writeln;
- Write ('Do you want to continue (enter Y or N )? ');
- Read( Kbd , YesNo );
- Write( YesNo );
- Until( YesNo In ['Y','y','N','n'] );
-
- If YesNo In ['N','n'] Then
- Begin
- Writeln;
- Writeln('OK, this program will stop now.');
- Close( PcTalkF );
- Close( QmodemF );
- Halt;
- End
- Else
- Begin
- Writeln;
- Writeln('OK, this program will continue.');
- Close( QmodemF );
- End;
-
- End;
- (* Open QMODEM.FON for output. *)
- (* Verify QMODEM.FON opened. *)
- (* Abort if not. *)
- Assign( QmodemF , 'QMODEM.FON' );
- (*$I-*)
- Rewrite( QmodemF );
- (*$I+*)
-
- If IOResult <> 0 Then
- Begin
- Writeln(' Can''t open the QMODEM.FON file for output.');
- Close( PcTalkF );
- Halt;
- End;
-
- End (* Open_Files *);
-
- (* --------------------------------------------------------------------- *)
- (* Transfer_Entries --- Transfer PC-Talk to QMODEM entries *)
- (* --------------------------------------------------------------------- *)
-
- Procedure Transfer_Entries;
-
- (* --------------------------------------------------------------------- *)
- (* *)
- (* Procedure: Transfer_Entries *)
- (* *)
- (* Purpose: Transfer PC-Talk entries to QMODEM entries. *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Transfer_Entries; *)
- (* *)
- (* Calls: IO_Check *)
- (* *)
- (* Called By: PctQmd *)
- (* *)
- (* --------------------------------------------------------------------- *)
-
- Var
- Error_Code : Integer;
- I : Integer;
-
- Begin (* Transfer_Entries *)
- (* Zero count of PC-Talk entries read.*)
- (* Different versions of PC-Talk *)
- (* have different size dialing *)
- (* directories. *)
-
- PcTalk_Count := 0;
- (* Ignore first few records of the *)
- (* PcTalk directory file. *)
-
- For I := 1 To PcTalk_Ignore Do
- Begin
- (* Read PC-Talk directory entry *)
- (*$I-*)
- Read ( PcTalkF , PcTalk_Entry );
- (*$I+*)
-
- (* Check if Read went OK *)
- IO_Check(' Error reading record from PC-Talk file', PcTalk_Count );
-
- End;
-
- (* Begin loop over PC-Talk entries. *)
- (* For each, transfer relevant data *)
- (* to corresponding entry in QMODEM *)
- (* phone directory file. *)
-
- While ( NOT EOF( PcTalkF ) ) Do
- Begin
- (* Read PC-Talk directory entry *)
- (*$I-*)
- Read ( PcTalkF , PcTalk_Entry );
- (*$I+*)
- (* Increment count of entries read *)
- PcTalk_Count := PcTalk_Count + 1;
-
- (* Check if Read went OK *)
- IO_Check(' Error reading record from PC-Talk file', PcTalk_Count );
-
- (* Transfer info to QMODEM entry *)
- Qmodem_Entry.Name := PcTalk_Entry.Name + ' ';
- Qmodem_Entry.Number := PcTalk_Entry.Number;
-
- VAL( TRIM( PcTalk_Entry.Speed ), Qmodem_Entry.Speed, Error_Code );
- VAL( PcTalk_Entry.Dbits , Qmodem_Entry.Dbits, Error_Code );
- VAL( PcTalk_Entry.Sbits , Qmodem_Entry.Sbits, Error_Code );
-
- Case PcTalk_Entry.Parity OF
- 'E': Qmodem_Entry.Parity := Even;
- 'O': Qmodem_Entry.Parity := None;
- 'N': Qmodem_Entry.Parity := None;
- Else
- Qmodem_Entry.Parity := None;
- End;
-
- (* Write out QMODEM entry *)
- (*$I-*)
- Write( QmodemF , Qmodem_Entry );
- (*$I+*)
- (* Check if Write went OK *)
- IO_Check(' Error writing record to Qmodem file', PcTalk_Count );
-
- End;
-
- Writeln;
- Writeln( PcTalk_Count, ' PC-Talk phone directory entries copied to Qmodem ',
- 'directory file QMODEM.FON.');
- Writeln;
- Delay( 2000 );
-
- End (* Transfer_Entries *);
-
- (* --------------------------------------------------------------------- *)
- (* Get_Default_Qmodem_Entry --- Read default QMODEM settings. *)
- (* --------------------------------------------------------------------- *)
-
- Procedure Get_Default_Qmodem_Entry;
-
- (* --------------------------------------------------------------------- *)
- (* *)
- (* Procedure: Get_Default_Qmodem_Entry *)
- (* *)
- (* Purpose: Reads default QMODEM directory values for padding out *)
- (* QMODEM.FON file. *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Get_Default_Qmodem_Entry; *)
- (* *)
- (* Calls: None *)
- (* *)
- (* Called By: PctQmd *)
- (* *)
- (* --------------------------------------------------------------------- *)
-
- Var
- D_Char : Char;
- D_Speed : Integer;
- D_Dbits : Integer;
- D_Sbits : Integer;
- D_Parity : Check_Bit;
- D_OK : Boolean;
- YesNo : Char;
-
- Begin (* Get_Default_Qmodem_Entry *)
-
- D_OK := FALSE;
-
- While ( NOT D_OK ) Do
- Begin
-
- Repeat
- Writeln;
- Write('Enter choice for default baud rate: 1) 300 2) 1200: ');
- Read( Kbd , D_Char );
- Write( D_Char );
- Until ( D_Char IN ['1', '2'] );
-
- If D_Char = '1' Then D_Speed := 300
- Else D_Speed := 1200;
-
- Repeat
- Writeln;
- Write('Enter choice for default number of data bits: 7 or 8: ');
- Read( Kbd , D_Char );
- Write( D_Char );
- Until ( D_Char IN ['7','8'] );
-
- If D_Char = '7' Then D_Dbits := 7
- Else D_Dbits := 8;
-
- Repeat
- Writeln;
- Write('Enter choice for default number of stop bits: 1 or 2: ');
- Read( Kbd , D_Char );
- Write( D_Char );
- Until ( D_Char IN ['1','2'] );
-
- If D_Char = '1' Then D_Sbits := 1
- Else D_Sbits := 2;
-
- Repeat
- Writeln;
- Write('Enter choice for default parity: 1) Even 2) None: ');
- Read( Kbd , D_Char );
- Write( D_Char );
- Until ( D_Char IN ['1','2'] );
-
- If D_Char = '1' Then D_Parity := Even
- Else D_Parity := None;
-
- Repeat
- Writeln;
- Write('Are these defaults OK? (Enter Y or N): ');
- Read( Kbd , YesNo );
- Write( YesNo );
- Until ( YesNo IN ['Y','y','N','n'] );
-
- D_OK := ( YesNo IN ['Y','y'] );
-
- End (* While D_OK *);
-
- Writeln;
-
- With Default_Qmodem_Entry Do
- Begin
- Name := '-------------------------';
- Number := '- --- --- ----';
- Speed := D_Speed;
- Dbits := D_Dbits;
- Sbits := D_Sbits;
- Parity := D_Parity;
- End;
-
- End (* Get_Default_Qmodem_Entry *);
-
- (* --------------------------------------------------------------------- *)
- (* Pad_With_Default --- Pad out QMODEM file with default entries *)
- (* --------------------------------------------------------------------- *)
-
- Procedure Pad_With_Default;
-
- (* --------------------------------------------------------------------- *)
- (* *)
- (* Procedure: Pad_With_Default *)
- (* *)
- (* Purpose: Pads out QMODEM directory file with default (blank) *)
- (* entries. *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Pad_With_Default; *)
- (* *)
- (* Calls: IO_Check *)
- (* *)
- (* Called By: PctQmd *)
- (* *)
- (* --------------------------------------------------------------------- *)
-
- Var
- I : Integer;
-
- Begin (* Pad_With_Default *)
-
- (* Pad QMODEM directory file with the *)
- (* default entry. *)
-
- For I := ( PcTalk_Count + 1 ) To Size_Of_Qmodem_File Do
- Begin
- (* Write out a default entry. *)
- Write( QmodemF , Default_Qmodem_Entry );
-
- (* Check if Write went OK *)
- IO_Check(' Error writing record to QMODEM file', I );
-
- End;
-
- End (* Pad_With_Default *);
-
- (* --------------------------------------------------------------------- *)
- (* PctQmd --- Main Program *)
- (* --------------------------------------------------------------------- *)
-
- Begin (* PctQmd *)
- (* Open PC-Talk, QMODEM directories. *)
- Open_Files;
- (* Obtain default QMODEM entry. *)
- Get_Default_Qmodem_Entry;
- (* Transfer PC-Talk entries to QMODEM.*)
- Transfer_Entries;
- (* Pad QMODEM directory file with the *)
- (* default entry. *)
- Pad_With_Default;
-
- (* Close files and exit normally. *)
- Close( QmodemF );
- Close( PcTalkF );
-
- End (* PctQmd *).